package com.lam.common.components.dict.model;

import java.util.HashSet;
import java.util.Set;

public class DictFeature {
	
	/** 是否把结果转换成json */
	private boolean transfer2Json;
	
	/** 是否删除原字段的值 */
	private boolean removeOrig;
	
	/** 是否进行深度遍历解析 */
	private boolean deep;
	
	/** 是否内部自动创建的 */
	private boolean isInner = false;
	
	private Set<Object> injectedSet;
	
	public DictFeature() {}
	
	public DictFeature(DictFeature dataFeature) {
		if(dataFeature != null) {
			this.transfer2Json = dataFeature.transfer2Json;
			this.removeOrig = dataFeature.removeOrig;
			this.deep = dataFeature.deep;
			this.isInner = true;
		}
	}
	
	public static DictFeature create(DictFeature dataFeature) {
		return dataFeature != null && dataFeature.isInner ? dataFeature : new DictFeature(dataFeature);
	}
	
	public static DictFeature create() {
		return new DictFeature();
	}
	
	public boolean injectedContains(Object o) {
		
		return injectedSet != null && injectedSet.contains(o);
	}

	public void addInjected(Object object) {
		if(object == null) {
			return ;
		}
		
		if(injectedSet == null) {
			injectedSet = new HashSet<>();
		}
		injectedSet.add(object);
	}
	
	public boolean transfer2Json() {
		return transfer2Json;
	}

	public DictFeature transfer2Json(boolean transfer2Json) {
		this.transfer2Json = transfer2Json;
		return this;
	}

	public boolean removeOrig() {
		return removeOrig;
	}

	public DictFeature removeOrig(boolean removeOrig) {
		this.removeOrig = removeOrig;
		return this;
	}

	public boolean deep() {
		return deep;
	}

	public DictFeature deep(boolean deep) {
		this.deep = deep;
		return this;
	}
	
	

}
